Skip to content

ci(review): report the Claude review as a commit status on the PR - #701

Merged
theCodeDrift merged 2 commits into
mainfrom
ci/claude-review-commit-status
Nov 17, 2026
Merged

theCodeDrift merged 2 commits into
mainfrom
ci/claude-review-commit-status

Conversation

@theCodeDrift

Copy link
Copy Markdown
Member

@claude /review runs are triggered by issue_comment, so GitHub runs them for the default branch: the run's own check is recorded on main's tip, never on the PR. A "wait for all checks" loop on the PR therefore finishes while the review is still running, and the tracking comment is no substitute, since it is edited many times and no edit marks the last one.

This posts a Claude Review commit status on the PR head commit the review checked out:

  • pending right after checkout, linked to the run;
  • success when the existing verify step finds a completed review from this run, failure when it does not, error when the run is cancelled. Set from an always() step, so a failed run never stays yellow. A runner that dies outright clears with a re-run.

The SHA is read from the checkout, not re-queried, so a push mid-review cannot move the status onto an unreviewed commit. The status is advisory, not required: most PRs are never reviewed, and a required status that is never posted stays pending forever.

statuses: write is added to the job. It is safe only while gh api stays off the model's --allowedTools (the model's environment holds the job token, and gh pr cannot set a status); the workflow header now says so. /focus is deliberately unchanged: it is a human asking where to look, not something an agent waits on.

Not exercised yet: comment-triggered workflows run from main, so the first real run is the first @claude /review after this merges.

A comment-triggered run is a run for the default branch, so its own check
lands on main's tip and never appears on the PR. Post a 'Claude Review'
status on the reviewed commit: pending while the review runs, then
success, failure or error from the job's outcome. Advisory, not required.
@theCodeDrift

Copy link
Copy Markdown
Member Author

@claude /review

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @theCodeDrift's task in 2m 58s —— View job


Review complete

Review mode: incremental — read 0 prior review thread(s) before reviewing. The only prior record on this PR is the trigger comment (@claude /review) itself, with no reviews, review bodies, or review threads — so this is effectively a first full review; I assessed the entire diff from scratch.

  • Read prior review data (none found — nothing to classify as addressed)
  • Fetch PR diff and full workflow file
  • Review diff for correctness/security/performance/clarity
  • Post findings

[New] One concrete correctness issue, posted inline on the new "Mark the review pending on the PR" step (lines 208–220): it has no always()/status-function if:, so GitHub Actions implicitly requires success() on every later step that also lacks one (which is every step up through "Run Claude Code Review"). A transient failure in posting the advisory pending status (e.g. a flaky gh api call) would therefore skip the entire rest of the pipeline — including the actual review step — turning a cosmetic status-posting hiccup into "no review ran." The final "failure" state would still get reported correctly (since Verify the review actually ran has always()), so it's not a silent failure, but it is a real review that should have happened and didn't, for a reason unrelated to reviewing. Suggested a simple || echo "::warning::..." guard on the gh api call so the step always exits 0 and the pipeline proceeds regardless.

Everything else checked out:

  • The statuses: write permission addition is correctly scoped and consistent with the existing gh api must-stay-off---allowedTools invariant documented in the header — --allowedTools is unchanged in this diff.
  • The SHA is read via git rev-parse HEAD from the already-checked-out tree (not re-queried from the PR), matching the stated goal of pinning the status to the reviewed commit rather than a later push.
  • job.status usage in the final step is valid (it's success/failure/cancelled per the Actions docs) and its placement after the verify step means it correctly reflects the verify step's verdict.
  • The final step's if: always() && steps.status.outputs.sha != '' guard correctly avoids posting any status when checkout itself never happened (e.g. invalid PR ref), since outputs written via $GITHUB_OUTPUT before a step's later failure are still preserved — so the one finding above is really the only gap.
  • gh api with -f fields correctly switches to POST per gh's own semantics, and the endpoint/context/fields match between the pending and final posts.

@theCodeDrift
theCodeDrift merged commit 45753c5 into main Nov 17, 2026
5 checks passed
@theCodeDrift
theCodeDrift deleted the ci/claude-review-commit-status branch November 17, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant